package com.vinyl.sound 
{
    import flash.events.*;
    import flash.media.Sound;
    import flash.media.SoundChannel;
	import flash.media.SoundTransform;
	
	/**
	 * ...
	 * @author 
	 */
	public class SoundPlayer
	{
		
		public var channel:SoundChannel; //사운드 이펙트 채널
		public var channel_b:SoundChannel; //배경 사운드 채널
		
		public var aaa = "aa";
		
		private static var instance:SoundPlayer;
		
		public function SoundPlayer()
		{
			if(instance != null)
			{
				throw new Error("DataService Singleton already constructed!");
			}
		}
		
		public static function getInstance():SoundPlayer
		{
			if(instance == null)
			{
				instance=new SoundPlayer();
			}
			
			return instance;
		}
		
		/**
		 * setVolume 볼륨조절
		 */
		public function setVolume(volume:Number):void {
			var transform:SoundTransform = channel_b.soundTransform;
			transform.volume = volume;
			channel_b.soundTransform = transform;
		}
		
		/**
		 * soundPlay 소리재생
		 */
		public function soundPlayBG( sound:Sound, volume:Number, startTime:Number ):void
		{
			channel_b = sound.play( startTime, 9000 );
			setVolume( volume )
		}
		
		/**
		 * setEfVolume 볼륨조절
		 */
		public function setEfVolume(volume:Number):void {

			var transform:SoundTransform = channel.soundTransform;
			transform.volume = volume;
			channel.soundTransform = transform;
		}
		
		/**
		 * soundPlay 소리재생
		 */
		public function soundPlay( sound:Sound, volume:Number, startTime:Number ):void
		{
			channel = sound.play( startTime );
			setEfVolume( volume )
		}
		
		//public function 
	}
}

